#include "MaterialTable.hpp"
#include "config.hpp"
#include "TimedVoxels.hpp"

namespace Dynamic
{

MaterialTable::~MaterialTable()
{
	delete[] Sigma_s;
	delete[] Sigma_a;
}

void MaterialTable::Init()
{
	for (int i = 0; i < nvoxels; i++) {
		Sigma_s[i] = 0.1;
		Sigma_a[i] = 0.0;
	}
}

double MaterialTable::sigma_a(int i, int j)
{
	return Sigma_a[TimedVoxels::VoxelIndex(i, j)];
}

double MaterialTable::sigma_s(int i, int j)
{
	return Sigma_s[TimedVoxels::VoxelIndex(i, j)];
}

MaterialTable& MaterialTable::operator=(const MaterialTable& mt)
{
	if (this == &mt) {
		return *this;
	}
	for (int i = 0; i < nvoxels; i++) {
		Sigma_s[i] = mt.Sigma_s[i];
		Sigma_a[i] = mt.Sigma_a[i];
	}
	return *this;
}

MaterialTable::MaterialTable(const MaterialTable& mt)
{
	Sigma_s = new double[nvoxels];
	Sigma_a = new double[nvoxels];
	for (unsigned int i = 0; i < nvoxels; i++) {
		Sigma_s[i] = mt.Sigma_s[i];
		Sigma_a[i] = mt.Sigma_a[i];
	}
}

MaterialTable::MaterialTable()
{
	Sigma_s = new double[nvoxels];
	Sigma_a = new double[nvoxels];
	Init();
}

}
